﻿

function shopEditAction() {  //shop修改提交action
    checkboxToStr('_classMain', 'classMain');
    checkboxToStr('_classOther', 'classOther');
    checkboxToStr('_classMore', 'classMore'); 
    document.forms[0].submit();
}
//jquery定位
//type:1,下部
//type:0,覆盖
//top:top校正值
//left:left校正值
function elLocation($obj, $taget, type, top, left) {
    top = top || 0;
    left = left || 0;

    var offset = $taget.offset()
    switch (type) {
        case 0:

            $obj.css("position", "absolute");
            $obj.css("top", offset.top + top);
            $obj.css("left", offset.left + left);

            break;
        default:

    }
}

//浮动层 基类
var floatPanle = function () {
    this.init.apply(this, arguments)
}
floatPanle.prototype = {
    //w:width,h:height,t:top,l:left;c:内容,mark:有无遮罩
    init: function (c, id, mark, markCallback) {
        this.markCallback = markCallback;
        if (mark == undefined) {
            this.mark = false;
        } else {
            this.mark = true;
        }
        this.id = id;
        if (id == undefined || id == "" || id == null) { return } else { this.getDom(id) };

        if (c != undefined) {
            this.pushContent(c);
        }

    },
    getDom: function (id) {

        if (this.has()) {

            this.dom = document.getElementById(id);
        } else {
            this.dom = document.body.appendChild(document.createElement("div"));
            this.dom.id = id;
            this.dom.className = "floatPanle"
        }
    },
    setClass: function (cls) {
        this.dom.className += " " + cls;
    },
    has: function () {

        if (document.getElementById(this.id)) { return true } else { return false; };
    },
    loc: function (w, h, t, l) {

        if (w) { this.w = w; this.dom.style.width = this.w + "px"; } else { this.w = $(this.dom).width(); }
        if (h) { this.h = h; this.dom.style.height = this.h + "px"; } else { this.h = $(this.dom).height() };

        if (t) { this.t = t; this.dom.style.top = this.t + "px"; } else {

            this.dom.style.top = document.documentElement.clientHeight / 2 - this.h / 2 + "px";
        }
        if (l) { this.l = l; this.dom.style.left = this.l + "px"; } else {
            this.dom.style.left = document.documentElement.clientWidth / 2 - this.w / 2 + "px";
        }
        return this;

    },
    show: function () {

        if (this.mark) {
            floatPanle.showMark(this.markCallback);
        }
        this.dom.style.display = "block";
    },


    pushContent: function (c) {
        this.dom.appendChild(c);
        c.style.display = "block"
        this.c = c;
    },
    hidden: function () {
        this.dom.style.display = "none";
        floatPanle.hideMark();
    },
    remove: function () {
        this.c.style.display = "none";
        document.body.appendChild(this.c)
    }
}

floatPanle.showMark = function (callback) {
    //    if (callback != null && callback != undefined) {
    //        floatPanle.markCallBack = callback;
    //    }

    var _markLayout = document.getElementById("maskLayout");
    if (_markLayout == null) {
        var maskhtmlstr = '<div id="maskLayout" style="position:absolute;top:0px; left:0px; background:#000;filter:alpha(opacity=50);-moz-opacity:0.5;-khtml-opacity: 0.5; opacity: 0.5;width:100px; height:100px"></div>';
        $("body").append(maskhtmlstr);
        _markLayout = document.getElementById("maskLayout");
    }

    if (typeof (callback) == "function") {
        $(_markLayout).unbind("click");
        $(_markLayout).bind("click", callback)
    }

    _markLayout.style.width = document.documentElement.clientWidth + "px";
    _markLayout.style.height = document.documentElement.clientHeight + "px";
    $("#maskLayout").show();
}
floatPanle.hideMark = function () {
    $("#maskLayout").hide();
}

//动作处理层
function actFloat(c, floatId, cls,mark,markCallback) {
    if (floatId == undefined || floatId == "") { floatId = "defaultFloadId" + new Date().UTC() }
    floatPanle.apply(this, [c, floatId, mark], markCallback);
    this.setClass(cls);
    this.$floatTarget = null;

}
actFloat.prototype = new floatPanle()


//同级元素选择
function setetedEl(it) {
    var $it = $(it);
    $it.parent().children(".selected").removeClass("selected");
    $it.addClass("selected");
}
//基础配置
var baseConfig = {
    siteThemePath:""
}

//
var actionTips = {
    html: '<div id="actionTipsLayout" class="actionTips_success"><div>',
    show: function (str, l, t) {
        var $x = $("#actionTipsLayout");
        if ($x.size() == 0) {
            $("body").append(actionTips.html);
            $x = $("#actionTipsLayout");
        }
        $x.html(str)
        $x.css("top", t)
        $x.css("left", l - 50);
        $x.css("opacity", 0);
        $x.show();
        $x.animate({ opacity: 1, top: "-=30" }, 300, 'swing').delay(400).animate({ opacity: 0, top: "-=30" }, 300, 'swing', function () { $(this).hide(); })

    }
}